home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d26 / cattest.arc / FLAMETMP.IN1 < prev    next >
Text File  |  1991-07-01  |  10KB  |  321 lines

  1. PROCEDURE Init_Question;
  2. VAR
  3.   dummy_i {integer, may be deleted}
  4.            {integer variables follow:}
  5.         : Integer;
  6.  
  7.        {real variables follow:}
  8.  dummy_r {real, may be deleted}
  9.   ,R_Heat_of_Formation_CH4
  10.   ,R_Heat_of_Formation_CO2
  11.   ,R_Heat_of_Formation_h2o
  12.   ,R_cp_CO2
  13.   ,R_cp_H2o
  14.   ,R_cp_n2
  15.   ,R_Heat_of_Combustion
  16.   ,R_cp_product_gases
  17.   ,R_final_temperature
  18.  : Real;
  19.  
  20.        {string variables follow:}
  21.  dummy_s {string, may be deleted}
  22.  ,A_R_Heat_of_Formation_CH4
  23.  ,A_R_Heat_of_Formation_CO2
  24.  ,A_R_Heat_of_Formation_h2o
  25.  ,A_R_cp_CO2
  26.  ,A_R_cp_H2o
  27.  ,A_R_cp_n2
  28.  ,A_R_Heat_of_Combustion
  29.  ,A_R_cp_product_gases
  30.  ,A_R_final_temperature
  31.  : String;
  32.  
  33. BEGIN
  34. {$I-}
  35. Assign (OldQuestionFile,Progname_string+'.SAV');
  36. Reset(OldQuestionFile);
  37. {$I+}
  38. IF IOResult = 0 THEN {this is a repeat, there was a .SAV file}
  39.    BEGIN
  40. ReadLn(OldQuestionFile,R_Heat_of_Formation_CH4);
  41. ReadLn(OldQuestionFile,R_Heat_of_Formation_CO2);
  42. ReadLn(OldQuestionFile,R_Heat_of_Formation_h2o);
  43. ReadLn(OldQuestionFile,R_cp_CO2);
  44. ReadLn(OldQuestionFile,R_cp_H2o);
  45. ReadLn(OldQuestionFile,R_cp_n2);
  46. ReadLn(OldQuestionFile,R_Heat_of_Combustion);
  47. ReadLn(OldQuestionFile,R_cp_product_gases);
  48. ReadLn(OldQuestionFile,R_final_temperature);
  49.   Close(OldQuestionFile);
  50.   END
  51.   else  {there was no .SAV file, must generate new values}
  52.   BEGIN
  53.  {question creation section 
  54.            creating new values for student variables}
  55.  
  56. R_Heat_of_Formation_CH4 := -74.81;
  57. R_Heat_of_Formation_CO2 := -395.51;
  58. R_Heat_of_Formation_h2o := -241.82;
  59. R_cp_CO2 := 37.11;
  60. R_cp_H2o := 33.58;
  61. R_cp_n2 := 29.12;
  62. R_Heat_of_Combustion := R_Heat_of_Formation_CO2+2.*R_Heat_of_Formation_h2o-R_Heat_of_Formation_CH4;
  63. R_cp_product_gases := R_cp_co2 + 2.*R_cp_h2o+8.*R_cp_n2;
  64. R_final_temperature := 298.-R_Heat_of_Combustion*(1.E3)/R_cp_product_gases;
  65.  ReWrite(OldQuestionFile);{ create the .SAV file just in case
  66.                             student needs to quit and do it again}
  67. WriteLn(OldQuestionFile,R_Heat_of_Formation_CH4);
  68. WriteLn(OldQuestionFile,R_Heat_of_Formation_CO2);
  69. WriteLn(OldQuestionFile,R_Heat_of_Formation_h2o);
  70. WriteLn(OldQuestionFile,R_cp_CO2);
  71. WriteLn(OldQuestionFile,R_cp_H2o);
  72. WriteLn(OldQuestionFile,R_cp_n2);
  73. WriteLn(OldQuestionFile,R_Heat_of_Combustion);
  74. WriteLn(OldQuestionFile,R_cp_product_gases);
  75. WriteLn(OldQuestionFile,R_final_temperature);
  76. Close(OldQuestionFile)
  77.   END;
  78.  
  79.  
  80. STR(R_Heat_of_Formation_CH4:4:2,A_R_Heat_of_Formation_CH4);
  81. STR(R_Heat_of_Formation_CO2:4:2,A_R_Heat_of_Formation_CO2);
  82. STR(R_Heat_of_Formation_h2o:4:2,A_R_Heat_of_Formation_h2o);
  83. STR(R_cp_CO2:4:2,A_R_cp_CO2);
  84. STR(R_cp_H2o:4:2,A_R_cp_H2o);
  85. STR(R_cp_n2:4:2,A_R_cp_n2);
  86. STR(R_Heat_of_Combustion:4:2,A_R_Heat_of_Combustion);
  87. STR(R_cp_product_gases:4:2,A_R_cp_product_gases);
  88. STR(R_final_temperature:4:2,A_R_final_temperature);
  89.  
  90.  
  91. question := ' For a stoichiometrically exact methane flame, assuming one mole of methane, ';
  92. question := question + ' calculate the theoretical flame temperature.';
  93. question := question + ' Cp CO2 =  ' + A_R_cp_CO2+' Delta_H(f) CO2 = ' + A_R_Heat_of_Formation_CO2;
  94. question := question + ' , Delta_H(f) CH4 = ' + A_R_Heat_of_Formation_CH4;
  95. question := question + ' , Cp H2O = ' + A_R_cp_H2O+' and Delta_H(f) H2O ' + A_R_Heat_of_Formation_H2O;
  96. question2 := 'while the Cp N2 = '+ A_R_cp_N2+' (in J/mole[cp] and kJ/mol[heats of formation]).';
  97.  
  98.  
  99. If MaxAvail < Sizeof(Wrong_Answers) then
  100.   BEGIN
  101.     WriteLn('Not enough memory');
  102.     Noise(Bad);
  103.     halt;
  104.   END ELSE
  105.   BEGIN
  106.     New(RootErrorPtr);
  107.     TempPtr := RootErrorPtr;
  108.     TempPtr^.next := nil;
  109.     TempPtr^.value := R_Heat_of_Combustion*(1.E3)/R_cp_product_gases;
  110.     TempPtr^.remark := 'Did you compute Delta(T)?';
  111.   END;
  112.  
  113.  
  114.  
  115. If MaxAvail < Sizeof(Wrong_Answers) then
  116.   BEGIN
  117.     WriteLn('Not enough memory');
  118.     Noise(Bad);
  119.     halt;
  120.   END ELSE
  121.   BEGIN
  122.     New(GenTempPtr);
  123.     TempPtr^.next := GenTempPtr;
  124.     TempPtr := GenTempPtr;
  125.     TempPtr^.next := nil;
  126.     TempPtr^.value := R_Heat_of_Combustion;
  127.     TempPtr^.remark := 'Did you compute the Heat of Combustion?';
  128.   END;
  129.  
  130. If MaxAvail < Sizeof(Wrong_Answers) then
  131.   BEGIN
  132.     WriteLn('Not enough memory');
  133.     Noise(Bad);
  134.     halt;
  135.   END ELSE
  136.   BEGIN
  137.     New(GenTempPtr);
  138.     TempPtr^.next := GenTempPtr;
  139.     TempPtr := GenTempPtr;
  140.     TempPtr^.next := nil;
  141.     TempPtr^.value := 298.+R_Heat_of_Combustion*(1.E3)/R_cp_product_gases;
  142.     TempPtr^.remark := 'Did you make a sign error?';
  143.   END;
  144.  
  145. If MaxAvail < Sizeof(Wrong_Answers) then
  146.   BEGIN
  147.     WriteLn('Not enough memory');
  148.     Noise(Bad);
  149.     halt;
  150.   END ELSE
  151.   BEGIN
  152.     New(GenTempPtr);
  153.     TempPtr^.next := GenTempPtr;
  154.     TempPtr := GenTempPtr;
  155.     TempPtr^.next := nil;
  156.     TempPtr^.value := 298.-R_Heat_of_Combustion/R_Cp_product_gases;
  157.     TempPtr^.remark := 'Did you forget a Joule or KJoule conversion?';
  158.   END;
  159.  
  160. If MaxAvail < Sizeof(Wrong_Answers) then
  161.   BEGIN
  162.     WriteLn('Not enough memory');
  163.     Noise(Bad);
  164.     halt;
  165.   END ELSE
  166.   BEGIN
  167.     New(GenTempPtr);
  168.     TempPtr^.next := GenTempPtr;
  169.     TempPtr := GenTempPtr;
  170.     TempPtr^.next := nil;
  171.     TempPtr^.value := true_answer/1000.;
  172.     TempPtr^.remark := 'Did you forget a power of 3?';
  173.   END;
  174.  
  175. true_answer := R_final_temperature;
  176.  
  177. {$IFDEF Watch_Student}
  178.  WriteLn(Outfile,Time_Stamp);
  179.  WriteLn(OutFile,question);
  180.  WriteLn(OutFile,'R_Heat_of_Formation_CH4 = ',R_Heat_of_Formation_CH4);
  181.  WriteLn(OutFile,'R_Heat_of_Formation_CO2 = ',R_Heat_of_Formation_CO2);
  182.  WriteLn(OutFile,'R_Heat_of_Formation_h2o = ',R_Heat_of_Formation_h2o);
  183.  WriteLn(OutFile,'R_cp_CO2 = ',R_cp_CO2);
  184.  WriteLn(OutFile,'R_cp_H2o = ',R_cp_H2o);
  185.  WriteLn(OutFile,'R_cp_n2 = ',R_cp_n2);
  186.  WriteLn(OutFile,'R_Heat_of_Combustion = ',R_Heat_of_Combustion);
  187.  WriteLn(OutFile,'R_cp_product_gases = ',R_cp_product_gases);
  188.  WriteLn(OutFile,'R_final_temperature = ',R_final_temperature);
  189.  WriteLn(OutFile,'answer = ',R_final_temperature);
  190. {$ENDIF }
  191.  
  192.  
  193. If MaxAvail < Sizeof(Debug_Lines) then
  194.     BEGIN
  195.       WriteLn('Not enough memory');
  196.       Noise(Bad);
  197.       halt;
  198.     END ELSE
  199.     BEGIN
  200.       New(RootDebugLinePtr);
  201.       TempDebugLinePtr := RootDebugLinePtr;
  202.       TempDebugLinePtr^.next := nil;
  203.       TempDebugLinePtr^.line := 'R_Heat_of_Formation_CH4 = ' + A_R_Heat_of_Formation_CH4;
  204.     END;
  205.  
  206. If MaxAvail < Sizeof(Debug_Lines) then
  207.     BEGIN
  208.       WriteLn('Not enough memory');
  209.       Noise(Bad);
  210.       halt;
  211.     END ELSE
  212.     BEGIN
  213.       New(GenTempDebugPtr);
  214.       TempDebugLinePtr^.next := GenTempDebugPtr;
  215.       TempDebugLinePtr := GenTempDebugPtr;
  216.       TempDebugLinePtr^.next := nil;
  217.       TempDebugLinePtr^.line := 'R_Heat_of_Formation_CO2 = ' + A_R_Heat_of_Formation_CO2;
  218.     END;
  219.  
  220. If MaxAvail < Sizeof(Debug_Lines) then
  221.     BEGIN
  222.       WriteLn('Not enough memory');
  223.       Noise(Bad);
  224.       halt;
  225.     END ELSE
  226.     BEGIN
  227.       New(GenTempDebugPtr);
  228.       TempDebugLinePtr^.next := GenTempDebugPtr;
  229.       TempDebugLinePtr := GenTempDebugPtr;
  230.       TempDebugLinePtr^.next := nil;
  231.       TempDebugLinePtr^.line := 'R_Heat_of_Formation_h2o = ' + A_R_Heat_of_Formation_h2o;
  232.     END;
  233.  
  234. If MaxAvail < Sizeof(Debug_Lines) then
  235.     BEGIN
  236.       WriteLn('Not enough memory');
  237.       Noise(Bad);
  238.       halt;
  239.     END ELSE
  240.     BEGIN
  241.       New(GenTempDebugPtr);
  242.       TempDebugLinePtr^.next := GenTempDebugPtr;
  243.       TempDebugLinePtr := GenTempDebugPtr;
  244.       TempDebugLinePtr^.next := nil;
  245.       TempDebugLinePtr^.line := 'R_cp_CO2 = ' + A_R_cp_CO2;
  246.     END;
  247.  
  248. If MaxAvail < Sizeof(Debug_Lines) then
  249.     BEGIN
  250.       WriteLn('Not enough memory');
  251.       Noise(Bad);
  252.       halt;
  253.     END ELSE
  254.     BEGIN
  255.       New(GenTempDebugPtr);
  256.       TempDebugLinePtr^.next := GenTempDebugPtr;
  257.       TempDebugLinePtr := GenTempDebugPtr;
  258.       TempDebugLinePtr^.next := nil;
  259.       TempDebugLinePtr^.line := 'R_cp_H2o = ' + A_R_cp_H2o;
  260.     END;
  261.  
  262. If MaxAvail < Sizeof(Debug_Lines) then
  263.     BEGIN
  264.       WriteLn('Not enough memory');
  265.       Noise(Bad);
  266.       halt;
  267.     END ELSE
  268.     BEGIN
  269.       New(GenTempDebugPtr);
  270.       TempDebugLinePtr^.next := GenTempDebugPtr;
  271.       TempDebugLinePtr := GenTempDebugPtr;
  272.       TempDebugLinePtr^.next := nil;
  273.       TempDebugLinePtr^.line := 'R_cp_n2 = ' + A_R_cp_n2;
  274.     END;
  275.  
  276. If MaxAvail < Sizeof(Debug_Lines) then
  277.     BEGIN
  278.       WriteLn('Not enough memory');
  279.       Noise(Bad);
  280.       halt;
  281.     END ELSE
  282.     BEGIN
  283.       New(GenTempDebugPtr);
  284.       TempDebugLinePtr^.next := GenTempDebugPtr;
  285.       TempDebugLinePtr := GenTempDebugPtr;
  286.       TempDebugLinePtr^.next := nil;
  287.       TempDebugLinePtr^.line := 'R_Heat_of_Combustion = ' + A_R_Heat_of_Combustion;
  288.     END;
  289.  
  290. If MaxAvail < Sizeof(Debug_Lines) then
  291.     BEGIN
  292.       WriteLn('Not enough memory');
  293.       Noise(Bad);
  294.       halt;
  295.     END ELSE
  296.     BEGIN
  297.       New(GenTempDebugPtr);
  298.       TempDebugLinePtr^.next := GenTempDebugPtr;
  299.       TempDebugLinePtr := GenTempDebugPtr;
  300.       TempDebugLinePtr^.next := nil;
  301.       TempDebugLinePtr^.line := 'R_cp_product_gases = ' + A_R_cp_product_gases;
  302.     END;
  303.  
  304. If MaxAvail < Sizeof(Debug_Lines) then
  305.     BEGIN
  306.       WriteLn('Not enough memory');
  307.       Noise(Bad);
  308.       halt;
  309.     END ELSE
  310.     BEGIN
  311.       New(GenTempDebugPtr);
  312.       TempDebugLinePtr^.next := GenTempDebugPtr;
  313.       TempDebugLinePtr := GenTempDebugPtr;
  314.       TempDebugLinePtr^.next := nil;
  315.       TempDebugLinePtr^.line := 'R_final_temperature = ' + A_R_final_temperature;
  316.     END;
  317.  
  318.  
  319. END {of .IN1};
  320.  
  321.